package com.lb.jwitter.action;


import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblThongTinHocVien;
import com.lb.jwitter.service.TblThongTinHocVienService;
import com.lb.jwitter.service.TblCTDTChuyenNganh;
import com.lb.jwitter.service.TblCTDTChuyenNganhService;

import com.lb.jwitter.service.TblCTDTKhoa;
import com.lb.jwitter.service.TblCTDTKhoaService;

import com.lb.jwitter.service.TblCTDTHeDaoTao;
import com.lb.jwitter.service.TblCTDTHeDaoTaoService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblThongTinHocVienAddFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private Collection<TblCTDTChuyenNganh> tblCTDTChuyenNganhs; 
    public Collection<TblCTDTChuyenNganh>  getTblCTDTChuyenNganhs(){ 
              return tblCTDTChuyenNganhs; 
     } 

    private TblCTDTChuyenNganhService tblCTDTChuyenNganhService; 

    private Collection<TblCTDTKhoa> tblCTDTKhoas; 
    public Collection<TblCTDTKhoa>  getTblCTDTKhoas(){ 
              return tblCTDTKhoas; 
     } 

    private TblCTDTKhoaService tblCTDTKhoaService; 

    private Collection<TblCTDTHeDaoTao> tblCTDTHeDaoTaos; 
    public Collection<TblCTDTHeDaoTao>  getTblCTDTHeDaoTaos(){ 
              return tblCTDTHeDaoTaos; 
     } 

    private TblCTDTHeDaoTaoService tblCTDTHeDaoTaoService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
    try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_ThongTin_HocVien", "them")){ 
        return "noprivilege"; 
    }        tblCTDTChuyenNganhService = (TblCTDTChuyenNganhService) context.getBean("tbl_CTDT_ChuyenNganhClient"); 

        tblCTDTKhoaService = (TblCTDTKhoaService) context.getBean("tbl_CTDT_KhoaClient"); 

        tblCTDTHeDaoTaoService = (TblCTDTHeDaoTaoService) context.getBean("tbl_CTDT_HeDaoTaoClient"); 

        tblCTDTChuyenNganhs = tblCTDTChuyenNganhService.findAlltblCTDTChuyenNganh(0, 0);

        tblCTDTKhoas = tblCTDTKhoaService.findAlltblCTDTKhoa(0, 0);

        tblCTDTHeDaoTaos = tblCTDTHeDaoTaoService.findAlltblCTDTHeDaoTao(0, 0);

        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi AddForm tbl_ThongTin_HocVien Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
